﻿using System;

namespace Program26
{
    class Program
    {
        //棋盘，定义为全局变量


        private static int[] Maps = new int[100];

        //玩家的姓名


        private static string[] PlayerNames = new string[2];





        //玩家走棋的坐标


        private static int[] PlayerPos = new int[2];





        private static void Main(string[] args)


        {


            #region 1.画游戏开头  GameShow()





            GameShow();





            #endregion 1.画游戏开头  GameShow()





            #region 2.输入玩家的姓名（变量 PlayerName[]）





            Console.ForegroundColor = ConsoleColor.White;


            Console.WriteLine("请输入玩家A的姓名：");


            PlayerNames[0] = Console.ReadLine();


            //检查用户输入的正确性


            while (string.IsNullOrEmpty(PlayerNames[0]))


            {


                Console.WriteLine("玩家A的姓名不能为空，请输入玩家A的姓名：");


                PlayerNames[0] = Console.ReadLine();


            }





            Console.WriteLine("请输入玩家B的姓名：");


            PlayerNames[1] = Console.ReadLine();


            while (string.IsNullOrEmpty(PlayerNames[1]) || PlayerNames[1] == PlayerNames[0])


            {


                if (string.IsNullOrEmpty(PlayerNames[1]))


                {


                    Console.WriteLine("玩家B的姓名不能为空，请输入玩家B的姓名：");


                    PlayerNames[1] = Console.ReadLine();


                }


                else


                {


                    Console.WriteLine("玩家B的姓名不能和玩家A相同，请输入玩家B的姓名：");


                    PlayerNames[1] = Console.ReadLine();


                }


            }


            //    打印玩家的姓名


            Console.Clear();


            GameShow();


            Console.ForegroundColor = ConsoleColor.White;


            Console.WriteLine("{0}的士兵用A表示", PlayerNames[0]);


            Console.WriteLine("{0}的士兵用B表示", PlayerNames[1]);





            #endregion 2.输入玩家的姓名（变量 PlayerName[]）





            // 3.初始化飞行棋地图 InitialMap()


            InitialMap();





            // 4.显示地图  DrawMap()


   +         DrawMap();





            // 5.循环走棋   只要任意玩家没有走到地图最后一个坐标  每次走棋执行相应的游戏规则 PlayGame()





            // 6.显示胜利画面





            //结束


            Console.ReadKey();


        }





        /// <summary>


        /// 开头画面


        /// </summary>


        public static void GameShow()


        {


            Console.ForegroundColor = ConsoleColor.Yellow;


            Console.WriteLine("***************************************************************");


            Console.ForegroundColor = ConsoleColor.Red;


            Console.WriteLine("***************************************************************");


            Console.ForegroundColor = ConsoleColor.Green;


            Console.WriteLine("***************************************************************");


            Console.ForegroundColor = ConsoleColor.White;


            Console.WriteLine("**************  软件工程演示项目：飞行棋1.0  ******************");


            Console.ForegroundColor = ConsoleColor.Blue;


            Console.WriteLine("***************************************************************");


            Console.ForegroundColor = ConsoleColor.Cyan;


            Console.WriteLine("***************************************************************");


            Console.ForegroundColor = ConsoleColor.DarkRed;


            Console.WriteLine("***************************************************************");


        }





        /// <summary>


        /// 初始化棋盘


        /// </summary>


        public static void InitialMap()


        {


            //幸运轮盘◎


            int[] luckyturn = { 6, 23, 40, 55, 68, 83 };


            for (var i = 0; i < luckyturn.Length; i++)


            {


                Maps[luckyturn[i]] = 1;   //值1表示幸运轮盘


            }
 
 

 
 
            //地雷☆

@@ -124,5 + 125,86 @@ namespace AirPlaneGame
 
 
                Maps[tunel[i]] = 4;   //值4表示时空隧道
 
 
            }


}





/// <summary>


/// 画出地图


/// </summary>


public static void DrawMap()


{


    Console.WriteLine("图例:幸运轮盘:◎   地雷:☆   暂停:▲   时空隧道:卐");


    //第一横行


    for (var i = 0; i < 30; i++)


        Console.Write(DrawMapPos(i));


    Console.WriteLine();





    //第一竖行


    for (var i = 30; i < 35; i++)


    {


        for (var j = 0; j < 29; j++)


        {


            Console.Write("  ");


        }





        Console.Write(DrawMapPos(i));


        Console.WriteLine();


    }





    //第二横行





    //第二竖行





    //第三横行


}





/// <summary>


/// 画棋盘的方法，根据坐标显示对应棋盘位置的字符


/// </summary>


/// <param name="i">坐标</param>


/// <returns></returns>


public static string DrawMapPos(int i)


{


    string str = "";


    //如果A B重合  显示<>


    if (PlayerPos[0] == PlayerPos[1] && PlayerPos[0] == i)


        str = "<>";


    else if (PlayerPos[0] == i)


        str = "A";


    else if (PlayerPos[1] == i)


        str = "B";


    else


    {


        //正常位置□  幸运轮盘:◎   地雷:☆   暂停:▲   时空隧道:卐


        switch (Maps[i])


        {


            case 0:


                Console.ForegroundColor = ConsoleColor.Yellow;


                str = "□";


                break;





            case 1:


                Console.ForegroundColor = ConsoleColor.Green;


                str = "◎";


                break;





            case 2:


                Console.ForegroundColor = ConsoleColor.Red;


                str = "☆";


                break;





            case 3:


                Console.ForegroundColor = ConsoleColor.Blue;


                str = "▲";


                break;





            case 4:


                Console.ForegroundColor = ConsoleColor.DarkCyan;


                str = "卐";


                break;


        }


    }





    return str;


}
 
 
    }
 
 
 
}